﻿using CompanyManageSystem.Model;
using CompanyManageSystem.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CompanyManageSystem.UI.WeiXin
{
    public partial class Frm_AddWeiXin : Form
    {
        #region 属性
        //管理员ID
        public Guid ManagerID { get; set; }
        //管理员
        public string Manager { get; set; }
        //保存事件
        public event EventHandler SaveEvent;
        #endregion

        #region 构造方法
        /// <summary>
        /// 构造方法
        /// </summary>
        public Frm_AddWeiXin(Guid managerID,string manager)
        {
            InitializeComponent();
            this.ManagerID = managerID;
            this.Manager = manager;
        }
        #endregion

        #region 界面加载完成
        /// <summary>
        /// 界面加载完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Frm_AddWeiXin_Load(object sender, EventArgs e)
        {
            
        }
        #endregion

        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_OK_Click(object sender, EventArgs e)
        {
            AppService aservice = new AppService();
            WeiXinInfo info = null;
            string text = this.InfoBox.Text.Trim();
            text = text.Replace("\r\n"," ");

            info = aservice.AddWeiXinInfo(this.ManagerID,this.Manager,text);

            this.Hide();
            MessageBox.Show("添加成功!","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Information);

            if (SaveEvent != null)
            {
                SaveEvent(info, new EventArgs());
            }
            this.Close();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Cancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }

}
